package com.zqu.controller;

import com.zqu.pojo.Car;
import com.zqu.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("car")
public class CarController {
    @Autowired
    private CarService carService;

    @RequestMapping("findcar")
    @ResponseBody
    public Car selectById(){
        return carService.selectCarById(1);
    }

    @RequestMapping("selectlist")
    @ResponseBody
    public List<Car> selectlist(){
        return carService.selectList(new Car());
    }

    @RequestMapping("insertcar")
    @ResponseBody
    public boolean insert(){
        return carService.insertCar(new Car());
    }

    @RequestMapping("updatecar")
    @ResponseBody
    public boolean update(){
        return carService.updateCar(new Car());
    }

    @RequestMapping("deletecar")
    @ResponseBody
    public boolean delete(){
        return carService.deleteCar(1);
    }

    @RequestMapping("deletecarbyids")
    @ResponseBody
    public boolean deletebyids(){
        String[] ids = {"1","2"};
        return carService.deleteCarByIds(ids);
    }
}
